package com.hn658.base.message.managermq.test;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.apache.activemq.command.ActiveMQDestination;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import com.hn658.base.message.managermq.JmsTemplateManager;


@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = { "classpath:spring.xml" })
public class JmsTemplateManagerClient {

	@Test
	public void activeMqCtextInitTest() {
//		JmsTemplate temp = JmsTemplateManager.get("ula", 0);
//		Assert.assertNotNull(temp);
	}
	
	@Test
	public void sendMessageTest() {
//		JmsTemplate temp = JmsTemplateManager.get("ula", 0);
//		ActiveMQDestination destination = (ActiveMQDestination) temp.getDefaultDestination();
//		temp.send(destination.getPhysicalName(), new MessageCreator() {
//			@Override
//			public Message createMessage(Session session) throws JMSException {
//				return session.createTextMessage("mq manager send config");
//			}
//		});
	}
	
	@Test
	public void receiveMessageTest() {
		
	}
}
